<template>
  <view class="editInfo">
    <view class="title"> 描述病情 </view>

    <view class="container">
      <view class="input-section">
        <u-input
          v-model="description"
          type="text"
          placeholder="请输入病情描述"
        />
      </view>
      <view class="tag-section">
        <view v-for="tag in tags" :key="tag" class="tag">
          {{ tag }}
        </view>
        <view class="tag-alert"> 胸痛 </view>
      </view>
      <view class="card-section">
        <view class="card">
          <view class="recording-icon" @click="startRecording">语音输入</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue'

const description = ref('') // 用户输入的病情描述
const tags = ref(['车祸', '摔倒', '晕倒']) // 标签列表

// 开始录音的函数
function startRecording() {
  console.log('开始录音')
  // TODO: 实现录音转文字的功能
}
</script>

<style lang="scss">
.editInfo {
  height: 100%;
  width: 100%;
  background-color: #ffffff;
  .title {
    color: #1f2937;
  }
  .container {
    margin: 20rpx;
    background-color: #f3f4f6;
    .input-section {
      margin-bottom: 40rpx;
      input {
        width: 100%;
        padding: 20rpx;
        font-size: 32rpx;
      }
    }

    .tag-section {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;

      .tag {
        padding: 10rpx 20rpx;
        margin-bottom: 20rpx;
        background-color: #eee;
      }

      .tag-alert {
        padding: 10rpx 20rpx;
        margin-bottom: 20rpx;
        background-color: red;
        color: white;
        animation: blinking 1s infinite;
      }
    }

    .card-section {
      width: 100%;
      margin-top: 40rpx;
      background-color: blue;
      position: absolute;
      bottom: 0;
      .card {
        background-color: blue;
        padding: 40rpx;
        background-color: #f5f5f5;
        display: flex;
        justify-content: center;
        align-items: center;

        .recording-icon {
          width: 100rpx;
          height: 100rpx;
          // background: url('/path/to/recording-icon.png') no-repeat center;
          background-size: contain;
        }
      }
    }
  }
}
@keyframes blinking {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}
</style>
